package com.cainaer.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cainaer.common.core.utils.DateUtils;
import com.cainaer.shop.domain.ShopInfo;
import com.cainaer.shop.mapper.ShopInfoMapper;
import com.cainaer.shop.service.IShopInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商铺信息表 服务实现类
 * </p>
 *
 * @author Tina
 * @since 2020-09-03
 */
@Service
public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements IShopInfoService {


    @Autowired
    private ShopInfoMapper shopInfoMapper;


    /**
     * 新增商家信息
     *
     * @param shopInfo
     * @return
     */
    @Override
    public Integer insertShopInfo(ShopInfo shopInfo) {
        shopInfo.setCreateTime(DateUtils.getTime());
        return shopInfoMapper.insert(shopInfo);
    }


    /**
     * 编辑商家信息
     *
     * @param shopInfo
     * @return
     */
    @Override
    public Integer editShopInfoByShop(ShopInfo shopInfo) {
        UpdateWrapper wrapper = new UpdateWrapper();
        wrapper.eq("shop_id", shopInfo.getShopId());
        return shopInfoMapper.update(shopInfo, wrapper);
    }

    /**
     * 查询商家信息
     *
     * @param shopId
     * @return
     */
    @Override
    public ShopInfo queryShopInfoByShopId(Long shopId) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("shop_id", shopId);
        return shopInfoMapper.selectOne(wrapper);
    }


}
